<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp"%>
<!DOCTYPE html>
<html>
<head>
  <title>资金上交和拨付统计</title>
  <style type="text/css">
  	.layui-form-label {
    float: left;
    display: block;
    padding: 9px 15px;
    width: 85px;
    font-weight: 400;
    line-height: 20px;
    text-align: right;
}
  </style>
</head>
<body>
  <div class="layui-fluid">   
    <div class="layui-card">
      <!-- 查询区域  -->
      <div id="query-form" class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">         
          <div class="layui-inline">
            	<label class="layui-form-label">费用归属公司</label>
            	<div class="layui-input-inline" style="width:280px;">
              		<select name="orgTypeAndId" id="query_select_orgId" lay-filter="query_select_orgId" lay-search >
	              		<c:if test="${not empty orgInfos }">
	              			<c:forEach items="${orgInfos}" var="org">
	              				<option value="${org.id}-${org.types}" <c:if test="${org.id == bindOrgId }">selected</c:if>>${org.compName }</option>
		            		</c:forEach>
	              		</c:if>
	              	</select>
            	</div>
          	</div>
          	<div class="layui-inline">
            	<label class="layui-form-label">统计期间</label>
            	<div class="layui-input-inline">
              		<input type="text" class="layui-input" id="sts_month_start"  name="stsMonthStart" readonly placeholder="开始月份">
            	</div>
            	<div class="layui-form-mid">
               	-
            	</div>
            	<div class="layui-input-inline">
              		<input type="text" class="layui-input" id="sts_month_end" name="stsMonthEnd" readonly placeholder="结束月份">
            	</div>
           </div>
          	<shiro:hasPermission name="LIST_FUNDS_HAND_AND_APPN">
	          <div class="layui-inline">
	            <button class="layui-btn layuiadmin-btn-admin" lay-submit lay-filter="LAY-fundsHandAndAppn-search">
	              <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
	            </button>
	          </div>
          	</shiro:hasPermission>
        </div>
      </div>
      <div class="layui-card-body">
	      	<div class="layui-tab layui-tab-brief" lay-filter="component-tabs-brief">
	        	<ul class="layui-tab-title">
	            	<li class="layui-this" lay-id="fundsHand"><B>资金上交</B></li>
	                <li lay-id="fundsAppn"><B>资金拨付</B></li>
	            </ul>
	            <div class="layui-tab-content">
	            	<div class="layui-tab-item layui-show">
	        			<table id="LAY-fundsHand-manage" lay-filter="LAY-fundsHand-manage"></table>
	                </div>
	                <div class="layui-tab-item">
	                    <table id="LAY-fundsAppn-manage" lay-filter="LAY-fundsAppn-manage"></table>
	                </div>
	            </div>
	        </div>      
      </div>
    </div>
  </div>
  <script>
  var stageJSON = <infopub:dicJson groupNo="A00010077" />;
  	layui.config({
    	base: '${ctx}/resources/layuiadmin/' //静态资源所在路径
  	}).extend({
    	index: 'lib/index' //主入口模块
  	}).use(['index', 'table', 'set', 'laydate', 'element'], function(){
    	var $ = layui.$
    	,form = layui.form
    	,table = layui.table
    	,laydate = layui.laydate
    	,element = layui.element;
    	
    	//tab重新渲染宽度
    	element.on('tab(component-tabs-brief)', function(obj){
    		$(window).resize();
    	});
    	
    	var insStart = laydate.render({
	      elem: '#sts_month_start'
	      ,type: 'month'
	      ,btns: ['now', 'confirm']
	      ,format:'yyyy年MM月'
	      ,value: layui.util.toDateString(new Date().getTime(), 'yyyy年MM月') //30天前
	      ,done:function(value, date){
	    	  //更新结束日期的最小日期
  	          insEnd.config.min = lay.extend({}, date, {
  	              month: date.month - 1
  	          });
	  	        
  	          //自动弹出结束日期的选择器
	  	      insEnd.config.elem[0].focus();
  	          
	      	  table.reload('LAY-fundsHand-manage', {page: {curr: 1},
			 	 where: {'stsMonthStart':value,'stsMonthEnd':$("#sts_month_end").val(),'orgTypeAndId':$('#query_select_orgId').val()}
		      });
	      	  table.reload('LAY-fundsAppn-manage', {page: {curr: 1},
			 	 where: {'stsMonthStart':value,'stsMonthEnd':$("#sts_month_end").val(),'orgTypeAndId':$('#query_select_orgId').val()}
		      });
	      }
	    });
	    
    	var insEnd = laydate.render({
	      elem: '#sts_month_end'
	      ,type: 'month'
	      ,btns: ['now', 'confirm']
	      ,format:'yyyy年MM月'
	      ,value: layui.util.toDateString(new Date().getTime(), 'yyyy年MM月') //30天前
	      ,done:function(value, date){
	    	  //更新开始日期的最大日期
        	  insStart.config.max = lay.extend({}, date, {
	  	          month: date.month - 1
	  	      });
	    	  
	      	  table.reload('LAY-fundsHand-manage', {page: {curr: 1},
			 	 where: {'stsMonthStart':$("#sts_month_start").val(),'stsMonthEnd':value,'orgTypeAndId':$('#query_select_orgId').val()}
		      });
	      	  table.reload('LAY-fundsAppn-manage', {page: {curr: 1},
			 	 where: {'stsMonthStart':$("#sts_month_start").val(),'stsMonthEnd':value,'orgTypeAndId':$('#query_select_orgId').val()}
		      });
	      }
	    });
	    
		form.on('select(query_select_orgId)', function(data){
   		 	table.reload('LAY-fundsHand-manage', {page: {curr: 1},
		 		where: {'stsMonthStart':$('#sts_month_start').val(),'stsMonthEnd':$('#sts_month_end').val(),'orgTypeAndId':$('#query_select_orgId').val()}
	      	});
   		 	table.reload('LAY-fundsAppn-manage', {page: {curr: 1},
		 		where: {'stsMonthStart':$('#sts_month_start').val(),'stsMonthEnd':$('#sts_month_end').val(),'orgTypeAndId':$('#query_select_orgId').val()}
	      	});
    	});
		
		var stsMonthStart = $('#sts_month_start').val();
		var stsMonthEnd = $('#sts_month_end').val();
    	// 资金上交表单
    	table.render({
      		elem: '#LAY-fundsHand-manage'
      		,url: basePath + '/fundsHandAndAppn/queryData1' //请求数据接口
      		,where: {'stsMonthStart':stsMonthStart,'stsMonthEnd':stsMonthEnd,'orgTypeAndId':$('#query_select_orgId').val()}
      		,cols: [[
					{type:'numbers', title: '序号',fixed:'left', width: 120, align:'center'}
					,{field: 'hrOrgName', title: '费用归属公司',fixed:'left',width: 280, align:'center'}
					,{field: 'codes', title: '单据编号',fixed:'left',width: 220, align:'center'}
					,{field: 'handDate', title: '资金上交日期',width: 220, align:'center', templet: function(d){	
							return layui.util.toDateString(d.handDate,"yyyy-MM-dd");
	              		}
	             	}
					,{field: 'handType', title: '上交类型',width: 220, align:'center', templet: function(d){
							if(d.handType=='01'){
								return "融资款";
							}else if(d.handType=='02'){
								return "日常经营借款";
							}else if(d.handType=='03'){
								return "项目回款";
							}else if(d.handType=='04'){
								return "政府资本金";
							}else if(d.handType=='05'){
								return "政府借款";
							}else if(d.handType=='06'){
								return "政府补贴";
							}else if(d.handType=='07'){
								return "指标收入";
							}else if(d.handType=='08'){
								return "中央财政基金";
							}else if(d.handType=='09'){
								return "回购款";
							}else if(d.handType=='10'){
								return "税款退还";
							}else if(d.handType=='11'){
								return "经营返点";
							}
						}
					}
					,{field: 'handAmount', title: '上交金额（元）',width: 220, align:'center', templet: function(d){
							return formatCurrency(d.handAmount);	
						}
					}
				  ]]
      		,page: true
      		,limit: 10
    	});

    	// 资金拨付表单
    	table.render({
      		elem: '#LAY-fundsAppn-manage'
      		,url: basePath + '/fundsHandAndAppn/queryData2' //请求数据接口
      		,where: {'stsMonthStart':stsMonthStart,'stsMonthEnd':stsMonthEnd,'orgTypeAndId':$('#query_select_orgId').val()}
      		,cols: [[
					{type:'numbers', title: '序号',fixed:'left', width: 120, align:'center'}
					,{field: 'hrOrgName', title: '费用归属公司',fixed:'left',width: 280, align:'center'}
					,{field: 'codes', title: '单据编号',fixed:'left',width: 220, align:'center'}
					,{field: 'appnDate', title: '资金拨付日期',width: 220, align:'center', templet: function(d){	
							return layui.util.toDateString(d.appnDate,"yyyy-MM-dd");
	              		}
	             	}
					,{field: 'appnType', title: '拨付类型',width: 220, align:'center', templet: function(d){
							if(d.appnType=='01'){
								return "工程款";
							}else if(d.appnType=='02'){
								return "建设资金";
							}else if(d.appnType=='03'){
								return "前期费用";
							}else if(d.appnType=='04'){
								return "日常经营借款";
							}else if(d.appnType=='05'){
								return "投标保证金";
							}else if(d.appnType=='06'){
								return "投资款";
							}else if(d.appnType=='07'){
								return "注册资本金";
							}else if(d.appnType=='08'){
								return "资金调剂";
							}else if(d.appnType=='09'){
								return "资信证明";
							}
						}
					}
					,{field: 'appnAmount', title: '拨付金额（元）',width: 220, align:'center', templet: function(d){
							return formatCurrency(d.appnAmount);	
						}
					}
				  ]]
      		,page: true
      		,limit: 10
    	});
    	
    	<shiro:hasPermission name="LIST_FUNDS_HAND_AND_APPN">
	    	//监听搜索
	    	form.on('submit(LAY-fundsHandAndAppn-search)', function(data){
	    		var tabId = $(".layui-tab-title .layui-this").attr("lay-id");
	    		if(tabId == 'fundsHand'){
	    			//执行重载
			      	table.reload('LAY-fundsHand-manage', {page: {curr: 1},
			        	where: trimData(data)
			      	});
	    		}else{
	    			//执行重载
			      	table.reload('LAY-fundsAppn-manage', {page: {curr: 1},
			        	where: trimData(data)
			      	});
	    		}
	    	});
    	</shiro:hasPermission>
  });
  	
  </script>
</body>
</html>

